www.gusucode.com > VC++ SMS 串口的阻塞模式短信彩信的收发-源码程序 > VC++ SMS 串口的阻塞模式短信彩信的收发-源码程序/code/sms_block.cpp
//Download by http://www.NewXing.com // sms_block.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <stdlib.h> #include <windows.h> #include "./sms/ComSms.h" void __stdcall funReadSMS(const char* szText, const char* szPhone, const char* szTime) { printf("%s:%s:%s\n", szText, szPhone, szTime); } int main(int argc, char* argv[]) { int nRet = COM_Open("COM1"); if ( nRet == FALSE ) { printf("打开串口失败\n"); system("pause"); return 0; } nRet = COM_SMS_Init(); if ( nRet == FALSE ) { printf("初始化短信模块失败\n"); system("pause"); return 0; } nRet = COM_SMS_SetReadFun(funReadSMS); //彩信模块 nRet = COM_SMS_SendMMS("智安邦", "测试", "b.jpg", "861358195****"); if ( nRet == FALSE ) { printf("发送彩信失败!\n"); system("pause"); return 0; } // nRet = COM_SMS_SetAddr("8613800100500", "8613581950725"); // if ( nRet == FALSE ) // { // printf("设置手机号码失败\n"); // system("pause"); // return 0; // } // // // nRet = COM_SMS_SendText("收到了吗?", NULL, true); // if ( nRet == FALSE ) // { // printf("发送短信失败\n"); // system("pause"); // return 0; // } // // nRet = COM_SMS_SetAddr("8613800100500", "8610086"); // nRet = COM_SMS_SendText("YE", NULL, true); // if ( nRet == FALSE ) // { // printf("发送短信失败\n"); // system("pause"); // return 0; // } system("pause"); COM_SMS_Uninit(); COM_Close(); printf("Hello World!\n"); return 0; }